#pragma once

struct MessageBuffer {
    std::string buffer;

    std::string GetAllData() {
        return buffer;
    }

    std::string GetDataUntilCrLf() {
        size_t pos = buffer.find("\r\n");
        if(pos == std::string::npos) {
            return "";
        }
        std::string data = buffer.substr(0, pos);
        buffer.erase(0, pos + 2);
        return data;
    }

    void Append(const char* data, size_t len) {
        buffer.append(data, len);
    }

    void Append(const std::string& data) {
        buffer.append(data);
    }

    size_t Size() {
        return buffer.size();
    }
};